package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/10/05 23:25
 **/
public class Day34_5_Num203_RemoveElements {
    class Solution {
        public ListNode removeElements(ListNode head, int val) {
            ListNode dummyHead = new ListNode(-1);
            ListNode cur = dummyHead;
            dummyHead.next = head;

            while(cur.next != null){
                if(cur.next.val == val) cur.next = cur.next.next;
                else cur = cur.next;
            }
            return dummyHead.next;
        }
    }
}